//
//  GLWXManager.h
//  health
//
//  Created by zglee on 2/11/20.
//  Copyright © 2020 zglee. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "BabyBluetooth.h"

#define mBluetoothNameLBM @"LBM-1" //LBM-1
#define mBluetoothNameRCM @"RCM" //RCM 

#define newBLEServerUUIDString @"6E400001-B5A3-F393-E0A9-E50E24DCCA9E" //5.0蓝牙
#define newBLEWriteUUIDString @"6E400002-B5A3-F393-E0A9-E50E24DCCA9E"
#define newBLEReadUUIDString @"6E400003-B5A3-F393-E0A9-E50E24DCCA9E"

#define writeServerUUIDString @"FFE5"
#define writeUUIDString @"FFE9"

#define readServerUUIDString @"FFE0"
#define readUUIDString @"FFE4"

#define bloodUricAcidType     @"A3"
#define urineUricAcidType     @"A6"
#define bloodSugarType     @"A2"
#define totalCholesterolType     @"A4"
#define hemoglobinType     @"A5" //血红蛋白

#define deviceTypeL01     @"68"
#define deviceTypeL02     @"78"
#define deviceTypeL03     @"88"
#define deviceTypeL04     @"87"

#define unitmgdL     @"mg/dL"
#define unitμmolL     @"μmol/L"
#define unitgdL     @"g/dL"
#define unitmmolL     @"mmol/L"
#define unitgL     @"g/L"

#define bloodUricAcidAbbr     @"UA"
#define urineUricAcidAbbr     @"UUA"
#define bloodSugarAbbr     @"Glu"
#define totalCholesterolAbbr     @"TC"
#define hemoglobinAbbr     @"HB"

typedef NS_ENUM(NSUInteger, DetectionPaperType) {
    DetectionPaperTypeUA,
    DetectionPaperTypeUUA,
    DetectionPaperTypeGlu,
    DetectionPaperTypeTC,
    DetectionPaperTypeHB,
   
};
@protocol BabyBlueToothManagerDelegate <NSObject>

//定时器回调
@optional
- (void)beginSearchDeviceList;

/// 获取试纸检测类型
@optional
- (void)blueToothManagerDetectionPaperType:(DetectionPaperType)detectionPaperType detectionItemType:(DetectionItemType)detectionItemType;

/// 试纸错误码
@optional
- (void)blueToothManagerErrorType:(NSString *)errorType;

@end

@interface BabyBlueToothManager : NSObject

+ (instancetype)shared;

/// 蓝牙管理器
@property (nonatomic, strong) BabyBluetooth *baby;

/// 设备类型
@property (nonatomic, copy) NSString* deviceType;

/// 检测试纸类型
@property (nonatomic, assign) DetectionPaperType detectionPaperType;

/// 设备
@property (nonatomic, strong) CBPeripheral *peripheral;

@property (nonatomic, strong) CBCharacteristic *characteristics;

@property (nonatomic, strong) NSMutableArray *peripherals;  /**< 搜索到的蓝牙设备列表 */

@property (nonatomic, strong) CBCentralManager *central;/**< 蓝牙连接状态 */

//写数据特征值
@property (nonatomic, strong) CBCharacteristic *writeCharacteristic;

//重复传数据
@property (assign,nonatomic) bool repeatflag;

//主动断开连接
@property (assign,nonatomic) bool selfDisconnection;

//重复传类型数据
@property (assign,nonatomic) bool repeatTypeflag;

//是否4合一检测
@property (assign,nonatomic) bool isDisease4;

@property (assign,nonatomic) NSInteger repeatTypeCount;

@property (nonatomic, strong) NSMutableDictionary *detectionValueDic;/**< 接收到数据 */

/**
 *  开始扫描
 */
-(void)startScan;

/**
 *  结束扫描
 */
-(void)stopScan;

@property (nonatomic,strong) NSTimer *timerReloadList;

//断开连接
- (void)cancelPeripheral;

/**
 连接蓝牙
 */
- (void)connetBlueToothWithCBPeripheral:(CBPeripheral *)peripheral;

//代理
@property(nonatomic,weak) id<BabyBlueToothManagerDelegate> delegate;

@end

